#include <gtest/gtest.h>

#include "memdb/memdb.h"
#include "memdb/impl/mock/MockTable.h"
#include "app/app.h"

TEST(TestBiz, testApplication){
	app::Application app;
	app.run();
}




TEST(TestBiz, testDataGrid){
	//memdb::impl::MockDB db("./data");
	memdb::impl::mock::MockTable table100; //= db.tables().get("order").;
	ASSERT_EQ((size_t)0, table100.count());

	{
		app::DataGrid dg;
		ASSERT_EQ(0, dg.current());


		dg.setDataSource(table100);
		ASSERT_EQ(&table100, &(dg.dataSource()));
		ASSERT_EQ(0, dg.current());


		dg.down(1);
		ASSERT_EQ(0, dg.current());

		dg.up(1);
		ASSERT_EQ(0, dg.current());

		dg.pagesDown(1);
		ASSERT_EQ(0, dg.current());

		dg.pagesUp(1);
		ASSERT_EQ(0, dg.current());

		dg.pagesDown(10);
		ASSERT_EQ(0, dg.current());

		dg.pagesUp(10);
		ASSERT_EQ(0, dg.current());
	}
}

/*  
//msg stream -> insert /replace
//destroy dataset 
//query: 
//	range() with default order 
//	range() with time-order(time + pk)
//filter:
//	range() with  filter + default-order
//	range() with filter + time-order
TEST(MemDBFullTest, ev_recv_order){
	db->install(TableDescribes::fromJson(tables_json));

	//sql::Operator -> sql::Replace/Insert/Query/Delete/Update

	//Dynamic
	//sql::PairInOrder data, sql::PairHash
	//
	//sql::PairBinaryKey data;
	sql::PairStringKey data;
	data.integer("id", 10)
		.string("col1", "hello")
		.string("col2", "hello2")
		.binary("col3", ptr, len, free)
		;
	//static 
	//Pair * data = OrderData::ValuefromHash(hashmap);
	//Pair * data = OrderData(1, 2, 3, 4);

	sql::memdb::OrderReplace replace("tbl_order", data);
	order.replace(replace.sql());

	sql::memdb::OrderQueryRange queryRange("tbl_order", sql::Filter, sql::Order);
	order.query(queryRange.range(0, 10).sql());


	db->uninstall();
}
*/
